//
//  HomeInputVIew.swift
//  NDAi
//
//  Created by 丸子 on 2024/6/4.
//

import UIKit

class HomeInputVIew: UIView {
    
    lazy var backView: UIView = {
       let view = UIView()
        view.backgroundColor = .clear
        view.allRound(18)
        view.layer.borderWidth = 0.5
        view.layer.borderColor = UIColor.white.cgColor
        return view
    }()
    
    lazy var sendBtn: UIButton = {
        let button = UIButton(type: .custom)
        button.setImage(UIImage(named: "icon_home_send"), for: .normal)
        button.setImage(UIImage(named: "icon_home_loading"), for: .selected)
        return button
    }()
    
    lazy var inputFiled: UITextField = {
        let textField = UITextField()
        textField.attributedPlaceholder = NSAttributedString.init(string: "输入你想问的...", attributes: [NSAttributedString.Key.font: UIFont.pingFangSCRegular(ofSize: 14), NSAttributedString.Key.foregroundColor: Theme.color.text_d3])
        textField.font = UIFont.pingFangSCRegular(ofSize: 16)
        textField.borderStyle = .none
        textField.textColor = .white
        textField.keyboardType = .default
        return textField
    }()
     
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor(hexString: "#58576D")
        corners([.layerMinXMinYCorner, .layerMaxXMinYCorner], cornerRadius: 10)
        addSubviews([sendBtn, backView])
        backView.addSubview(inputFiled)
        sendBtn.snp.makeConstraints { make in
//            make.centerY.equalToSuperview()
            make.top.equalToSuperview().offset(10)
            make.trailing.equalToSuperview().offset(-16)
            make.width.height.equalTo(32)
        }
        
        backView.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(10)
            make.leading.equalToSuperview().offset(16)
            make.height.equalTo(36)
            make.trailing.equalTo(sendBtn.snp.leading).offset(-12)
        }
        
        inputFiled.snp.makeConstraints { make in
            make.leading.equalTo(12)
            make.centerY.equalToSuperview()
            make.trailing.equalTo(-12)
            make.height.equalTo(30)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
}
